package com.lyf.scm.common.util.style;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

/**
 * excel处理工具类
 *
 * @author wangchlei
 * @date 2020/08/19
 */
public class ExcelCellHandleUtil {

    /**
     * 获取单元格中的文本内容
     *
     * @param cell
     * @return {@link String}
     **/
    public static String getCellStringValue(Cell cell) {
        if (cell == null) {
            return "";
        }
        CellType cellType = cell.getCellTypeEnum();
        switch (cellType) {
            case STRING:
                return cell.getRichStringCellValue().getString();
            case NUMERIC:
                return String.valueOf(cell.getNumericCellValue());
            default:
                return "";
        }
    }
}
